load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
    name = "calculation",
    srcs = ["calculation.cc"],
    hdrs = ["calculation.h"],
    deps = [
        ":value_source",
        "//tachyon/base/strings:string_util",
        "//tachyon/zk/plonk/vanishing:evaluation_input",
    ],
)

tachyon_cc_library(
    name = "custom_gate_evaluator",
    hdrs = ["custom_gate_evaluator.h"],
    deps = [
        "//tachyon/base:profiler",
        "//tachyon/base/containers:container_util",
        "//tachyon/zk/plonk/constraint_system:gate",
        "//tachyon/zk/plonk/vanishing:circuit_polynomial_builder_forward",
        "//tachyon/zk/plonk/vanishing:graph_evaluator",
        "//tachyon/zk/plonk/vanishing:vanishing_utils",
    ],
)

tachyon_cc_library(
    name = "circuit_polynomial_builder",
    hdrs = ["circuit_polynomial_builder.h"],
    deps = [
        ":evaluation_input",
        ":graph_evaluator",
        ":vanishing_utils",
        "//tachyon/base:parallelize",
        "//tachyon/base/containers:adapters",
        "//tachyon/zk/base:rotation",
        "//tachyon/zk/lookup:prover",
        "//tachyon/zk/plonk/base:column_key",
        "//tachyon/zk/plonk/keys:proving_key_forward",
        "//tachyon/zk/plonk/permutation:permutation_prover",
        "//tachyon/zk/shuffle:prover",
        "@com_google_absl//absl/types:span",
    ],
)

tachyon_cc_library(
    name = "circuit_polynomial_builder_forward",
    hdrs = ["circuit_polynomial_builder_forward.h"],
)

tachyon_cc_library(
    name = "evaluation_input",
    hdrs = ["evaluation_input.h"],
    deps = ["//tachyon/zk/plonk/base:multi_phase_ref_table"],
)

tachyon_cc_library(
    name = "graph_evaluator",
    hdrs = ["graph_evaluator.h"],
    deps = [
        ":calculation",
        "//tachyon/zk/expressions:constant_expression",
        "//tachyon/zk/expressions:evaluator",
        "//tachyon/zk/expressions:negated_expression",
        "//tachyon/zk/expressions:product_expression",
        "//tachyon/zk/expressions:scaled_expression",
        "//tachyon/zk/expressions:sum_expression",
        "//tachyon/zk/plonk/expressions:advice_expression",
        "//tachyon/zk/plonk/expressions:challenge_expression",
        "//tachyon/zk/plonk/expressions:fixed_expression",
        "//tachyon/zk/plonk/expressions:instance_expression",
        "//tachyon/zk/plonk/expressions:selector_expression",
    ],
)

tachyon_cc_library(
    name = "value_source",
    srcs = ["value_source.cc"],
    hdrs = ["value_source.h"],
    deps = [
        "//tachyon:export",
        "//tachyon/base:logging",
        "//tachyon/zk/plonk/vanishing:evaluation_input",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "vanishing_argument",
    hdrs = ["vanishing_argument.h"],
    deps = [
        ":circuit_polynomial_builder",
        ":custom_gate_evaluator",
        "//tachyon/zk/lookup:evaluator",
        "//tachyon/zk/plonk/constraint_system",
        "//tachyon/zk/plonk/permutation:permutation_evaluator",
        "//tachyon/zk/shuffle:evaluator",
    ],
)

tachyon_cc_library(
    name = "vanishing_prover",
    hdrs = [
        "vanishing_prover.h",
        "vanishing_prover_impl.h",
    ],
    deps = [
        ":vanishing_argument",
        ":vanishing_utils",
        "//tachyon/base:parallelize",
        "//tachyon/base:profiler",
        "//tachyon/crypto/commitments:polynomial_openings",
        "//tachyon/math/base:parallelize_threshold",
        "//tachyon/zk/lookup:prover",
        "//tachyon/zk/plonk/base:multi_phase_ref_table",
        "//tachyon/zk/plonk/keys:proving_key",
        "//tachyon/zk/plonk/permutation:permutation_prover",
        "//tachyon/zk/shuffle:prover",
    ],
)

tachyon_cc_library(
    name = "vanishing_utils",
    hdrs = ["vanishing_utils.h"],
    deps = [
        "//tachyon/base:parallelize",
        "//tachyon/base/types:always_false",
        "//tachyon/math/elliptic_curves/bn/bn254:fr",
        "//tachyon/zk/base:blinded_polynomial",
        "//tachyon/zk/base/entities:prover_base",
        "//tachyon/zk/plonk/constraint_system:gate",
        "//tachyon/zk/plonk/halo2:config",
        "@com_google_absl//absl/types:span",
    ],
)

tachyon_cc_library(
    name = "vanishing_verifier",
    hdrs = ["vanishing_verifier.h"],
    deps = [
        ":vanishing_utils",
        ":vanishing_verifier_data",
        "//tachyon/crypto/commitments:polynomial_openings",
        "//tachyon/zk/plonk/expressions:verifying_evaluator",
    ],
)

tachyon_cc_library(
    name = "vanishing_verifier_data",
    hdrs = ["vanishing_verifier_data.h"],
    deps = ["//tachyon/zk/plonk/base:multi_phase_evaluations"],
)

tachyon_cc_unittest(
    name = "vanishing_unittests",
    srcs = [
        "graph_evaluator_unittest.cc",
        "value_source_unittest.cc",
        "vanishing_utils_unittest.cc",
    ],
    deps = [
        ":graph_evaluator",
        ":vanishing_utils",
        "//tachyon/base:random",
        "//tachyon/math/elliptic_curves/bn/bn254:g1",
        "//tachyon/math/finite_fields/test:finite_field_test",
        "//tachyon/math/polynomials/univariate:univariate_evaluation_domain_factory",
        "//tachyon/zk/plonk/expressions:expression_factory",
        "//tachyon/zk/plonk/expressions/evaluator/test:evaluator_test",
    ],
)
